I want to put something like the following code in an application I'm writing. The two subordinate procedures define something that I call "pseudovariables". (Anyone remember PL/I?)
Question: Is there any way to retain control in this situation? I would like to detect the attempt to assign to a read-only variable and tell the user that he can't do that. I was hoping to be able to do this:
pseudovar_2() +:= 2 | stop("Hey! Stop that!")
But it doesn't `fail'--it just suddenly croaks. Here is what I get when I run it:
pseudovar_1() = 1
pseudovar_1() = 2
pseudovar_2() = 1
Run-time error 111
File newpseudo.icn; Line 8
variable expected
offending value: 1
Traceback:
main()
{1 := 3} from line 8 in newpseudo.icn
Is there any other way to accomplish this end? It's for a split application: I write the numerical integration code, and presumably someone else writes code implementing the differential equation describing his problem, and links it to my prewritten integrator, which, I should not forget to add, contains main() and a bunch of predefined global variables beginning with "_". Some of these must be updated by the user, others must not be. So I would like to use this technique (or something better, if it exists) to manage the situation.